import SizeEnums from '@/model/enums/SizeEnums'
import BtnTypeEnums from '@/model/enums/BtnTypeEnums'
class BtnModel {
  /**
   * 定义索引类型为string
   */
  [index: string]: any
  /**
   * 按钮文本
   */
  public label: string = 'test'
  /**
   * 按钮点击事件
   */
  public click?: Function = () => {}
  /**
   * 尺寸
   */
  public size?: SizeEnums = SizeEnums.small
  /**
   * 按钮类型
   */
  public type?: BtnTypeEnums = BtnTypeEnums.info
  /**
   * 按钮图标
   */
  public icon?: string = ''

  public static danger = (btn: BtnModel): BtnModel => {
    btn.type = BtnTypeEnums.danger
    return new BtnModel(btn)
  }

  public static warning = (btn: BtnModel): BtnModel => {
    btn.type = BtnTypeEnums.warning
    return new BtnModel(btn)
  }

  public static success = (btn: BtnModel): BtnModel => {
    btn.type = BtnTypeEnums.success
    return new BtnModel(btn)
  }

  public static primary = (btn: BtnModel): BtnModel => {
    btn.type = BtnTypeEnums.primary
    return new BtnModel(btn)
  }
  public static text = (btn: BtnModel): BtnModel => {
    btn.type = BtnTypeEnums.text
    return new BtnModel(btn)
  }

  public static info = (btn: BtnModel): BtnModel => {
    btn.type = BtnTypeEnums.info
    return new BtnModel(btn)
  }

  constructor(arg: BtnModel) {
    for (let key of Object.keys(arg)) {
      this[key] = arg[key]
    }
  }
}
export default BtnModel
